package com.huanxing.cloud.mall.api.controller;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huanxing.cloud.common.core.entity.Result;
import com.huanxing.cloud.mall.api.service.UserWithdrawalApplyService;
import com.huanxing.cloud.mall.common.dto.UserWithdrawalApplyRequest;
import com.huanxing.cloud.mall.common.entity.UserWithdrawalApply;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 商城用户
 *
 * @author lijx
 * @since 2022/3/1 10:13
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/withdrawalapply")
@Api(value = "withdrawalapply", tags = "用户提现申请")
public class UserWithdrawalApplyController {

	private final UserWithdrawalApplyService userWithdrawalApplyService;

	@ApiOperation(value = "分页查询用户提现申请")
	@GetMapping("/page")
	public Result getPage(Page page, UserWithdrawalApply withdrawalApply) {
		return Result.success(userWithdrawalApplyService.page(page, Wrappers.query(withdrawalApply)));
	}

	@ApiOperation(value = "新增用户提现申请")
	@PostMapping("/add")
	public Result add(@Valid @RequestBody UserWithdrawalApplyRequest userWithdrawalApplyRequest) {
		return Result.success(userWithdrawalApplyService.add(userWithdrawalApplyRequest));
	}

}
